package com.tgy.树.二叉树;

/***
 * @ClassName: TestDelNode
 * @Description: 测试删除节点
 * @Auther: tanggy3
 * @Date: 16:04 2022/12/22
 * @version : V1.0
 */
public class TestDelNode {
    public static void main(String[] args) {
        //先需要创建一颗二叉树
        BinaryTree binaryTree = new BinaryTree();
        //创建需要的结点
        Node root = new Node(1, "宋江");
        Node node2 = new Node(2, "吴用");
        Node node3 = new Node(3, "卢俊义");
        Node node4 = new Node(4, "林冲");
        Node node5 = new Node(5, "关胜");

        //说明，我们先手动创建该二叉树，后面我们学习递归的方式创建二叉树
        root.leftNode = node2;
        root.rightNode = node3;
        node3.rightNode = node4;
        node3.leftNode = node5;
        binaryTree.setRoot(root);
        binaryTree.preOrder();
        System.out.println("==========");
        binaryTree.delNode(5);
        binaryTree.preOrder();
    }
}
